﻿// Copyright (c) Inossem. All rights reserved.
// Licensed under the LGPL-3.0 license. See LICENSE file in the project root for full license information.
using DWF.Studio.Custom;
using DWF.Studio.NuGetManagement;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Packaging;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DWF.Studio.Models
{
    /// <summary>
    /// 系统配置类
    /// </summary>
    internal class SysConfig
    {
        /// <summary>
        /// 活动库nuget 地址
        /// </summary>
        public string PackageUri
        {
            set;
            get;
        }
        /// <summary>
        /// 活动库nuget 地址
        /// </summary>
        public List<PackageSourceUri> PackageUris
        {
            set;
            get;
        }
        /// <summary>
        /// 平台地址
        /// </summary>
        public string FlatformUri
        {
            set;
            get;
        }

        /// <summary>
        /// 升级地址
        /// </summary>
        public string UpgradeUri
        {
            set;
            get;
        }

        /// <summary>
        /// 资产地址
        /// </summary>
        public string AssetsUri
        {
            set;
            get;
        }

        /// <summary>
        /// 工作空间
        /// </summary>
        public string WorkSpace
        {
            set;
            get;
        }

        /// <summary>
        /// 是否自动保存
        /// </summary>
        public bool IsAutoSave
        {
            set;
            get;
        }

        /// <summary>
        /// 执行日志保存到文件 Oliver 2021-06-16
        /// </summary>
        public bool IsLogToFile
        {
            get;
            set;
        }

        /// <summary>
        /// 执行输出保存到文件 Oliver 2021-06-17
        /// </summary>
        public bool IsConsoleOutToFile
        {
            get;
            set;
        }

        /// <summary>
        /// 静默执行，这种执行方式无任何输出，既无ui输出，亦无日志输出 Oliver 2021-06-17
        /// </summary>
        public bool IsSilentExecution
        {
            get;
            set;
        }
        /// <summary>
        /// 运行时最小化 命中断点弹出窗口
        /// </summary>
        public bool IsDebugShowWindow
        {
            get;
            set;
        }
        
        /// <summary>
        /// 自动保存时间间隔
        /// </summary>
        public TimeSpan? AutoSaveSpan
        {
            set;
            get;
        }

        public int LangugeId
        {
            set;
            get;
        }

        public List<PackageSourceUri> GetStablePackageUri()
        {
            var packageUris = this.PackageUris;
            var packageUri = this.PackageUri;
            if (!String.IsNullOrWhiteSpace(packageUri))
            {
                packageUris.Add(new PackageSourceUri("Custom", "Custom", packageUri, false));
            }
            return packageUris;
        }
    }
}
